texture Color;
sampler colorSampler = sampler_state
{
    Texture = <Color>;
    AddressU = Clamp;
    AddressV = Clamp;
    MagFilter = Point;
    MinFilter = Point;
    Mipfilter = Point;
};

texture Edge;
sampler edgeSampler = sampler_state
{
    Texture = <Edge>;
    AddressU = Clamp;
    AddressV = Clamp;
    MagFilter = Point;
    MinFilter = Point;
    Mipfilter = Point;
};

texture NormalEdge;
sampler normalEdgeSampler = sampler_state
{
    Texture = <NormalEdge>;
    AddressU = Clamp;
    AddressV = Clamp;
    MagFilter = Point;
    MinFilter = Point;
    Mipfilter = Point;
};

texture Depth;
sampler depthSampler = sampler_state
{
    Texture = <Depth>;
    AddressU = Clamp;
    AddressV = Clamp;
    MagFilter = Point;
    MinFilter = Point;
    Mipfilter = Point;
};

texture Light;
sampler lightSampler = sampler_state
{
    Texture = <Light>;
    AddressU = Clamp;
    AddressV = Clamp;
    MagFilter = Point;
    MinFilter = Point;
    Mipfilter = Point;
};

struct ShaderData
{
    float4 Position : POSITION0;
    float2 TexCoord : TEXCOORD0;
};

ShaderData VertexShaderFunction(ShaderData input)
{
    return input;
}

float4 PixelShaderFunction(float2 screenCoord : TEXCOORD0) : COLOR0
{
    float4 light = tex2D(lightSampler, screenCoord);
    float4 color = tex2D(colorSampler, screenCoord);
    float4 edge = tex2D(edgeSampler, screenCoord);
    float4 depth = tex2D(depthSampler, screenCoord);
    float4 normalEdge = tex2D(normalEdgeSampler, screenCoord);

    light *= 4;
    light.r = round(light.r);
    light.g = round(light.g);
    light.b = round(light.b);
    light /= 4;

    //float e = pow(normalEdge, 2) * (0.6f - depth);
    float e = pow(normalEdge, 2);//pow(normalEdge, 2 + depth) * (1 - depth);
    return float4(color * light.rgb + light.a - e, 1);
}

technique Technique1
{
    pass Pass1
    {
        VertexShader = compile vs_2_0 VertexShaderFunction();
        PixelShader = compile ps_2_0 PixelShaderFunction();
    }
}
